vec2 = {x=0,y=0}
class(vec2)

function vec2:new(x,y)
	self.x = x or 0
	self.y = y or 0
end

-- operator overload for + example: a + b
function vec2:add(a,b)
	local bx,by = b,b
	if type(b) == "table" then bx,by = b.x,b.y end
	return vec2(a.x + bx, a.y + by)
end

-- operator overload for - example: a - b
function vec2:sub(a,b)
	local bx,by = b,b
	if type(b) == "table" then bx,by = b.x,b.y end
	return vec2(a.x - bx, a.y - by)
end

-- operator overload for unary - example: -a
function vec2:unm(a)
	return vec2(-a.x, -a.y)
end

-- operator overload for * example: a * b
function vec2:mul(a,b)
	local bx,by = b,b
	if type(b) == "table" then bx,by = b.x,b.y end
	return vec2(a.x * bx, a.y * by)
end

-- operator overload for / example: a / b
function vec2:div(a,b)
	local bx,by = b,b
	if type(b) == "table" then bx,by = b.x,b.y end
	return vec2(a.x / bx, a.y / by)
end

-- operator overload for % (modulus) example: a % b
function vec2:mod(a,b)
	local bx,by = b,b
	if type(b) == "table" then bx,by = b.x,b.y end
	return vec2(a.x % bx, a.y % by)
end

--fancy tostring override ("vec2 [x,y]")
function vec2:tostring()
	return "vec2 ["..self.x..","..self.y.."]"
end

--[[ demo codes
local test = vec2(100,100)
print(tostring(test))
test = test + 10
print(tostring(test))
]]--